package com.cbs.android.extension.glide.sample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.cbs.android.extension.glide.target.RoundedImageViewTarget;
import com.cbs.android.extension.glide.urlloader.qiniu.QiniuUrlLoader;
import com.cbs.android.extension.glide.urlloader.qiniu.url.AvatarUrl;
import com.cbs.android.extension.glide.urlloader.qiniu.url.LimitShortUrl;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = MainActivity.class.getName();
    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imageView = (ImageView) findViewById(R.id.imageview);

    }

    public void basic(View view) {
        Glide.with(this).load("http://image.guguxinge.com/13m-3800x1200.png").into(imageView);
    }

    public void loader(View view) {
        Glide.with(this).using(new QiniuUrlLoader(this)).load(new LimitShortUrl("http://image.guguxinge.com/13m-3800x1200.png", true)).into(imageView);
    }

    public void rounded(View view) {
        Glide.with(this).using(new QiniuUrlLoader(this)).load(new AvatarUrl("http://image.guguxinge.com/13m-3800x1200.png", true)).asBitmap().into(new RoundedImageViewTarget(imageView));
//        Glide.with(this).using(new QiniuUrlLoader(this)).load(new AvatarUrl("http://image.guguxinge.com/13m-3800x1200.png")).transform(new CircleTransformation(this)).into(imageView);
    }
}
